package algotithm.jianzhioffer.test14;

/**
 * @author zhouyanxiang
 * @Date 2020-12-2020/12/16-14:14
 */
public class Solution2 {

    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        int res = solution2.cuttingRope(120);
        System.out.println(res);
    }

    public int cuttingRope(int n) {
        long res = 1;
        if (n <= 3) {
            return (n - 1);
        }
        if (n % 3 == 1) {
            res = 4;
            n -= 4;
        } else if (n % 3 == 2) {
            res = 2;
            n -= 2;
        }
        while (n > 0) {
            res = (res * 3);
            res = res % 1000000007;
            n -= 3;
        }
        return (int) res;
    }
}
